/*
 * Copyright 2017 Baiyyy
 * @(#)ColdStorageService.java
 */

package com.byyy.ccts.modules.cc.service.impl;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.byyy.ccts.core.common.service.impl.CommonServiceImpl;
import com.byyy.ccts.core.query.data.PageImpl;
import com.byyy.ccts.core.query.data.Pageable;
import com.byyy.ccts.core.query.data.Queryable;
import com.byyy.ccts.core.query.parse.QueryToWrapper;
import com.byyy.ccts.modules.cc.entity.ccts.TACouvense;
import com.byyy.ccts.modules.cc.mapper.CouvenseMapper;
import com.byyy.ccts.modules.cc.service.ICouvenseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by DELL on 2018-6-13.
 */
@Transactional
@Service("couvenseService")
public class CouvenseService extends CommonServiceImpl<CouvenseMapper, TACouvense> implements ICouvenseService {

    /**
     * 装车单明细内查询的保温箱列表
     * @param queryable
     * @param wrapper
     * @return
     */
    public com.byyy.ccts.core.query.data.Page<TACouvense> couvenseListForZcdMx(Queryable queryable, Wrapper<TACouvense> wrapper, String zhuangcdNo) {
        QueryToWrapper<TACouvense> queryToWrapper = new QueryToWrapper<>();
        queryToWrapper.parseCondition(wrapper, queryable);
        // 排序问题
        queryToWrapper.parseSort(wrapper, queryable);
        Pageable pageable = queryable.getPageable();
        com.baomidou.mybatisplus.plugins.Page<TACouvense> page = new com.baomidou.mybatisplus.plugins.Page<TACouvense>(
                pageable.getPageNumber(), pageable.getPageSize());
        com.baomidou.mybatisplus.plugins.Page<TACouvense> content = couvenseListPageForZcdMx(page, wrapper, zhuangcdNo);
        return new PageImpl<TACouvense>(content.getRecords(), queryable.getPageable(), content.getTotal());
    }

    /**
     * 装车单明细内查询的保温箱列表
     * @param page
     * @param wrapper
     * @return
     */
    public Page<TACouvense> couvenseListPageForZcdMx(Page<TACouvense> page, Wrapper<TACouvense> wrapper, String zhuangcdNo) {
        page.setRecords(baseMapper.selectCouvensePage(page, wrapper, zhuangcdNo));
        return page;
    }


}
